package de.fhhannover.inform.itteam.snmpnetviz.gui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import de.fhhannover.inform.itteam.snmpnetviz.gui.util.ScaleImage;

public class KeyPanel extends JPanel {
	
	private final ImageIcon keyImage = new ImageIcon(getClass().getResource("/gfx/snmpNetViz/key.png"));

	private Image image;

	public KeyPanel(NVFrame frame) {
		int sizeX = Math.round(frame.getWidth() / 7);
		int sizeY = Math.round(sizeX*1.6f);
		
		ImageIcon scaledKeyImage = ScaleImage.resize(sizeX, sizeY, keyImage);
		Dimension size = new Dimension(
				scaledKeyImage.getIconWidth(), scaledKeyImage.getIconHeight());
		
		this.image = scaledKeyImage.getImage();
		
		// set size
		setOpaque(true);
		setBorder(null);
		setPreferredSize(size);
		setMinimumSize(size);
		setMaximumSize(size);
		setSize(size);
		repaint();
	}

	@Override
	public void paintComponent(Graphics g) {
		g.drawImage(image, 0, 0, null);
	}
}

